//
//  CYNextSpecialTableViewCell.m
//  KCZ_B段项目
//
//  Created by dllo on 15/11/4.
//  Copyright © 2015年 Sky. All rights reserved.
//

#import "CYNextSpecialTableViewCell.h"
#import "FitHeader.h"
#import <UIImageView+WebCache.h>
#import "FontSizeSingleTon.h"
#define FontSize [[FontSizeSingleTon shareFontSize]array]
@implementation CYNextSpecialTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self creatViews];
    }
    return self;
}


-(void)creatViews
{
    _photoImage = [[UIImageView alloc]initWithFrame:CGRectMake(15 * wt, 0, 345 * wt, 200 * ht)];
    _photoImage.backgroundColor = [UIColor grayColor];
    [self addSubview:_photoImage];
    
    _titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(230 * wt, 140 * ht, 130 * wt, 60 * ht)];
    _titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:[FontSize[1] integerValue]];
    _titleLabel.textColor = [UIColor whiteColor];
    _titleLabel.textAlignment = 1;
    _titleLabel.backgroundColor = [UIColor colorWithRed:arc4random() % 256 / 255.0 green:arc4random() % 256 / 255.0 blue:arc4random() % 256 / 255.0 alpha:0.5];
    [self addSubview:_titleLabel];
    
    _infoLabel = [[UILabel alloc]init];
    _infoLabel.numberOfLines = 0;
    _infoLabel.font = [UIFont systemFontOfSize:[FontSize[2] integerValue]];
    [self addSubview:_infoLabel];
}

-(void)setSpecial:(CYNextSpecialModel *)special
{
    if (_special != special) {
        _special = special;
    }
    [_photoImage sd_setImageWithURL:[NSURL URLWithString:special.Cover]placeholderImage:[UIImage imageNamed:@"345200"]];
    _titleLabel.text = special.Title;
    _infoLabel.text = special.Intro;
}
#pragma mark 自适应
-(void)setDataString:(NSString *)dataString
{
    NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:13], NSFontAttributeName, nil];
    CGRect rect = [dataString boundingRectWithSize:CGSizeMake(345 * wt, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    _infoLabel.text = dataString;
    _infoLabel.frame = CGRectMake(_photoImage.frame.origin.x, _photoImage.frame.origin.y + _photoImage.frame.size.height, 345 * wt, rect.size.height);
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
